<?php


namespace EchoPHP\Database\Exceptions;

use Exception;
use RuntimeException;

class TuxedoTransactionException extends RuntimeException {

    public function __construct($querys, Exception $previous) {
        parent::__construct('', 0, $previous);

        $this->code = $previous->code;
        $this->message = $this->formatMessage($querys, $previous);
    }

    /**
     * 格式化返回错误信息,拼接实际sql语句
     * @param $sql
     * @param $bindings
     * @param Exception $previous
     * @return string
     */
    protected function formatMessage($querys, Exception $previous) {
        return $previous->getMessage() . implode(' ', $querys);
    }

}